home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / macscheme.init < prev    next >
Text File  |  1999-04-19  |  8KB  |  268 lines

  1. ;;;"macscheme.init" Configuration of *features* for MacScheme    -*-scheme-*-
  2. ;;; Author: Aubrey Jaffer
  3. ;;;
  4. ;;; This code is in the public domain.
  5.  
  6. ;;; From: jjb@isye.gatech.edu (John Bartholdi)
  7.  
  8. ;;; (software-type) should be set to the generic operating system type.
  9. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  10.  
  11. (define (software-type) 'MACOS)
  12.  
  13. ;;; (scheme-implementation-type) should return the name of the scheme
  14. ;;; implementation loading this file.
  15.  
  16. (define (scheme-implementation-type) 'MacScheme)
  17.  
  18. ;;; (scheme-implementation-home-page) should return a (string) URL
  19. ;;; (Uniform Resource Locator) for this scheme implementation's home
  20. ;;; page; or false if there isn't one.
  21.  
  22. (define (scheme-implementation-home-page) #f)
  23.  
  24. ;;; (scheme-implementation-version) should return a string describing
  25. ;;; the version the scheme implementation loading this file.
  26.  
  27. (define (scheme-implementation-version) "4.2")
  28.  
  29. ;;; (implementation-vicinity) should be defined to be the pathname of
  30. ;;; the directory where any auxillary files to your Scheme
  31. ;;; implementation reside.
  32.  
  33. (define (implementation-vicinity) "Macintosh.HD:MacScheme 4.2:")
  34.  
  35. ;;; (library-vicinity) should be defined to be the pathname of the
  36. ;;; directory where files of Scheme library functions reside.
  37.  
  38. (define (library-vicinity) "Macintosh.HD:MacScheme 4.2:slib:")
  39.  
  40. ;;; (home-vicinity) should return the vicinity of the user's HOME
  41. ;;; directory, the directory which typically contains files which
  42. ;;; customize a computer environment for a user.
  43.  
  44. (define (home-vicinity) #f)
  45.  
  46. ;;; *FEATURES* should be set to a list of symbols describing features
  47. ;;; of this implementation.  Suggestions for features are:
  48.  
  49. (define *features*
  50.       '(
  51.     source                ;can load scheme source files
  52.                     ;(slib:load-source "filename")
  53. ;    compiled            ;can load compiled files
  54.                     ;(slib:load-compiled "filename")
  55.     rev4-report            ;conforms to
  56.     rev3-report            ;conforms to
  57.     ieee-p1178            ;conforms to
  58. ;    sicp                ;runs code from Structure and
  59.                     ;Interpretation of Computer
  60.                     ;Programs by Abelson and Sussman.
  61.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  62.                     ;LIST->STRING, STRING-COPY,
  63.                     ;STRING-FILL!, LIST->VECTOR,
  64.                     ;VECTOR->LIST, and VECTOR-FILL!
  65.     rev3-procedures            ;LAST-PAIR, T, and NIL
  66. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  67.                     ;SUBSTRING-MOVE-RIGHT!,
  68.                     ;SUBSTRING-FILL!,
  69.                     ;STRING-NULL?, APPEND!, 1+,
  70.                     ;-1+, <?, <=?, =?, >?, >=?
  71.     multiarg/and-            ;/ and - can take more than 2 args.
  72.     multiarg-apply            ;APPLY can take more than 2 args.
  73.     rationalize
  74.     delay                ;has DELAY and FORCE
  75.     with-file            ;has WITH-INPUT-FROM-FILE and
  76.                     ;WITH-OUTPUT-FROM-FILE
  77.     string-port            ;has CALL-WITH-INPUT-STRING and
  78.                     ;CALL-WITH-OUTPUT-STRING
  79. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  80. ;    char-ready?
  81. ;    macro                ;has R4RS high level macros
  82. ;    defmacro            ;has Common Lisp DEFMACRO
  83. ;    record                ;has user defined data structures
  84. ;    values                ;proposed multiple values
  85. ;    dynamic-wind            ;proposed dynamic-wind
  86.     ieee-floating-point        ;conforms to
  87.     full-continuation        ;can return multiple times
  88. ;    object-hash            ;has OBJECT-HASH
  89.  
  90. ;    sort
  91. ;    queue                ;queues
  92.     pretty-print
  93. ;    object->string
  94. ;    format
  95. ;    trace                ;has macros: TRACE and UNTRACE
  96.     compiler            ;has (COMPILER)
  97. ;    ed                ;(ED) is editor
  98. ;    system                ;posix (system <string>)
  99. ;    getenv                ;posix (getenv <string>)
  100. ;    program-arguments        ;returns list of strings (argv)
  101. ;    Xwindows            ;X support
  102. ;    curses                ;screen management package
  103. ;    termcap                ;terminal description package
  104. ;    terminfo            ;sysV terminal description
  105.     ))
  106.  
  107. ;;; (OUTPUT-PORT-WIDTH <port>)
  108. (define (output-port-width . arg) 79)
  109.  
  110. ;;; (OUTPUT-PORT-HEIGHT <port>)
  111. (define (output-port-height . arg) 24)
  112.  
  113. ;;; (CURRENT-ERROR-PORT)
  114. (define current-error-port
  115.   (let ((port (current-output-port)))
  116.     (lambda () port)))
  117.  
  118. ;;; (TMPNAM) makes a temporary file name.
  119. (define tmpnam (let ((cntr 100))
  120.          (lambda () (set! cntr (+ 1 cntr))
  121.              (string-append "slib_" (number->string cntr)))))
  122.  
  123. ;;; (FILE-EXISTS? <string>)
  124. (define (file-exists? f) #f)
  125.  
  126. ;;; (DELETE-FILE <string>)
  127. (define (delete-file f) #f)
  128.  
  129. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  130. ;;; use this definition if your system doesn't have such a procedure.
  131. (define (force-output . arg) #t)
  132.  
  133. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  134. ;;; port versions of CALL-WITH-*PUT-FILE.
  135. (define (call-with-output-string f)
  136.   (let ((outsp (open-output-string)))
  137.     (f outsp)
  138.     (let ((s (get-output-string outsp)))
  139.       (close-output-port outsp)
  140.       s)))
  141.  
  142. (define (call-with-input-string s f)
  143.   (let* ((insp (open-input-string s))
  144.      (res (f insp)))
  145.     (close-input-port insp)
  146.     res))
  147.  
  148. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  149. ;;; be returned by CHAR->INTEGER.
  150. (define char-code-limit 256)
  151.  
  152. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  153. (define most-positive-fixnum 536870911)
  154.  
  155. ;;; Return argument
  156. (define (identity x) x)
  157.  
  158. ;;; SLIB:EVAL is single argument eval using the top-level (user) environment.
  159. (define slib:eval eval)
  160.  
  161. ;;; If your implementation provides R4RS macros:
  162. ;(define macro:eval slib:eval)
  163. ;(define macro:load load)
  164.  
  165. (define *defmacros*
  166.   (list (cons 'defmacro
  167.           (lambda (name parms . body)
  168.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  169.                       *defmacros*))))))
  170. (define (defmacro? m) (and (assq m *defmacros*) #t))
  171.  
  172. (define (macroexpand-1 e)
  173.   (if (pair? e) (let ((a (car e)))
  174.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  175.                      (if a (apply (cdr a) (cdr e)) e))
  176.             (else e)))
  177.       e))
  178.  
  179. (define (macroexpand e)
  180.   (if (pair? e) (let ((a (car e)))
  181.           (cond ((symbol? a)
  182.              (set! a (assq a *defmacros*))
  183.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  184.             (else e)))
  185.       e))
  186.  
  187. (define gentemp
  188.   (let ((*gensym-counter* -1))
  189.     (lambda ()
  190.       (set! *gensym-counter* (+ *gensym-counter* 1))
  191.       (string->symbol
  192.        (string-append "slib:G" (number->string *gensym-counter*))))))
  193.  
  194. (define base:eval slib:eval)
  195. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  196. (define (defmacro:expand* x)
  197.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  198.  
  199. (define (defmacro:load <pathname>)
  200.   (slib:eval-load <pathname> defmacro:eval))
  201.  
  202. (define (slib:eval-load <pathname> evl)
  203.   (if (not (file-exists? <pathname>))
  204.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  205.   (call-with-input-file <pathname>
  206.     (lambda (port)
  207.       (let ((old-load-pathname *load-pathname*))
  208.     (set! *load-pathname* <pathname>)
  209.     (do ((o (read port) (read port)))
  210.         ((eof-object? o))
  211.       (evl o))
  212.     (set! *load-pathname* old-load-pathname)))))
  213.  
  214. (define slib:warn
  215.   (lambda args
  216.     (let ((port (current-error-port)))
  217.       (display "Warn: " port)
  218.       (for-each (lambda (x) (display x port)) args))))
  219.  
  220. ;;; define an error procedure for the library
  221. (define slib:error
  222.   (lambda args
  223.     (cerror "Error: " args)))
  224.  
  225. ;;; define these as appropriate for your system.
  226. (define slib:tab #\tab)
  227. (define slib:form-feed #\page)
  228.  
  229. ;;; Define these if your implementation's syntax can support it and if
  230. ;;; they are not already defined.
  231.  
  232. ;(define (1+ n) (+ n 1))
  233. ;(define (-1+ n) (+ n -1))
  234. ;(define 1- -1+)
  235.  
  236. (define in-vicinity string-append)
  237.  
  238. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  239. ;;; return if exitting not supported.
  240. ; MacScheme does not return a value when it exits,
  241. ; so simply invoke system procedure exit with 0 args.
  242. (define slib:exit (lambda args (exit)))
  243.  
  244. ;;; Here for backward compatability
  245. (define scheme-file-suffix
  246.   (let ((suffix (case (software-type)
  247.           ((NOSVE) "_scm")
  248.           (else ".scm"))))
  249.     (lambda () suffix)))
  250.  
  251. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  252. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  253.  
  254. ;(define slib:load-source load)
  255. (define (slib:load-source f) (load (string-append f (scheme-file-suffix))))
  256.  
  257. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  258. ;;; by compiling "foo.scm" if this implementation can compile files.
  259. ;;; See feature 'COMPILED.
  260.  
  261. (define slib:load-compiled load)
  262.  
  263. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  264.  
  265. (define slib:load slib:load-source)
  266.  
  267. (slib:load (in-vicinity (library-vicinity) "require"))
  268.